package com.wxapp.sale.service.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wxapp.common.constant.base.IBaseController;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.common.constant.pojo.vo.UserVo;
import com.wxapp.common.core.annotation.User;
import com.wxapp.sale.api.pojo.vm.order.POrderDetailVm;
import com.wxapp.sale.api.pojo.vm.order.POrderPageVm;
import com.wxapp.sale.api.pojo.vo.order.QChangeStatusVo;
import com.wxapp.sale.api.pojo.vo.order.QOrderAddVo;
import com.wxapp.sale.api.pojo.vo.order.QOrderPageVo;
import com.wxapp.sale.service.service.OrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author lgl
 * @Description 订单管理
 * @Datetime 2022/7/5 9:01
 * @Modified By
 */
@RestController
@Tag(name = "订单管理")
@RequestMapping("/order")
@RequiredArgsConstructor
public class OrderController extends IBaseController {

    private final OrderService orderService;

    @PostMapping("page")
    @Operation(summary ="订单分页表")
    public ResultVm<IPage<POrderPageVm>> page(@Schema(hidden = true) @User UserVo userVo, @RequestBody QOrderPageVo qOrderPageVo) {
        return orderService.page(userVo, qOrderPageVo);
    }
    @GetMapping("getOrderInfoByCode/{code}")
    @Operation(summary ="获取订单信息通过订单code")
    public ResultVm<POrderDetailVm> getOrderInfoByCode(@PathVariable String code){
        return orderService.getOrderInfo(code);
    }

    @PostMapping("add")
    @Operation(summary ="下单接口")
    public ResultVm<String> add(@Schema(hidden = true) @User UserVo userVo, @RequestBody QOrderAddVo add){
        return orderService.add(add, userVo);
    }

    @PostMapping("changeStatus")
    @Operation(summary ="更改订单状态")
    public ResultVm<String> changeStatus( @RequestBody QChangeStatusVo vo){
        return orderService.changeStatus(vo);
    }

}

